import { ApiProperty } from '@nestjs/swagger';

export class Runtime {
  @ApiProperty({ description: '系统' })
  os?: string;

  @ApiProperty({ description: '服务器架构' })
  arch?: string;

  @ApiProperty({ description: 'Node版本' })
  nodeVersion?: string;

  @ApiProperty({ description: 'Npm版本' })
  npmVersion?: string;
}

export class CoreLoad {
  @ApiProperty({ description: '当前CPU资源消耗' })
  rawLoad?: number;

  @ApiProperty({ description: '当前空闲CPU资源' })
  rawLoadIdle?: number;
}

// Intel(R) Xeon(R) Platinum 8163 CPU @ 2.50GHz
export class Cpu {
  @ApiProperty({ description: '制造商 e.g. Intel(R)' })
  manufacturer?: string;

  @ApiProperty({ description: '品牌	e.g. Core(TM)2 Duo' })
  brand?: string;

  @ApiProperty({ description: '物理核心数' })
  physicalCores?: number;

  @ApiProperty({ description: '型号' })
  model?: string;

  @ApiProperty({ description: '速度 in GHz e.g. 3.4' })
  speed?: number;

  @ApiProperty({ description: 'CPU资源消耗 原始滴答' })
  rawCurrentLoad?: number;

  @ApiProperty({ description: '空闲CPU资源 原始滴答' })
  rawCurrentLoadIdle?: number;

  @ApiProperty({ description: 'cpu资源消耗', type: [CoreLoad] })
  coresLoad?: CoreLoad[];
}

export class Disk {
  @ApiProperty({ description: '磁盘空间大小 (bytes)' })
  size?: number;

  @ApiProperty({ description: '已使用磁盘空间 (bytes)' })
  used?: number;

  @ApiProperty({ description: '可用磁盘空间 (bytes)' })
  available?: number;
}

export class Memory {
  @ApiProperty({ description: 'total memory in bytes' })
  total?: number;

  @ApiProperty({ description: '可用内存' })
  available?: number;
}

/**
 * 系统信息
 */
export class ServeStatInfo {
  @ApiProperty({ description: '运行环境', type: Runtime })
  runtime?: Runtime;

  @ApiProperty({ description: 'CPU信息', type: Cpu })
  cpu?: Cpu;

  @ApiProperty({ description: '磁盘信息', type: Disk })
  disk?: Disk;

  @ApiProperty({ description: '内存信息', type: Memory })
  memory?: Memory;
}

/**
 * canvas微服务
 */
export class ServeCanvasDto {
  @ApiProperty({ description: '数字，逗号隔开' })
  str?: string;
}

export class ImgPoint {
  text?: string;
  y: number;
  x: number;
  editor_scale?: number;
  image_width?: number;
  image_height?: number;
  scale?: number;
  rotate?: number;
  background?: any;
  componentType?: string;
  tempFilePath?: string;
  templateSizeArr?: number[];
  imgInfo?: {
    width: number; // 图片实际宽度
    height: number; // 图片实际高度
  };
  imgOriginalInfo?: {
    scale: number; // 图片相对于编辑区域的真实缩放比例，计算方法：imgInfo的宽度除以编辑区域内图片的宽度
  };
}
export class DrawImageConfig {
  url?: string;
  x?: number;
  y?: number;
  width?: number;
  height?: number;
  mode?: string;
  radius?: number;
  isRepeat?: boolean;
  repeatGoup?: {
    x: number;
    y: number;
    width: number;
    height: number;
  }[];
  imgPoint: ImgPoint;
}
export class canvasPaperSize {
  width: number;
  height: number;
}
export class modeInfo {
  @ApiProperty({ description: '媒体的宽高' })
  mediaInfo: { width: number; height: number };

  @ApiProperty({ description: '排版' })
  mediaSetTypeFormat: { column: number; row: number };
}

export class ImgOriginalInfo {
  @ApiProperty({ description: '缩放系数' })
  scale: number;

  @ApiProperty({ description: '左移' })
  left: number;

  @ApiProperty({ description: '顶部' })
  top: number;

  @ApiProperty({ description: '旋转' })
  rotate: number;
}

export class ImgInfo {
  @ApiProperty({ description: '可选' })
  errMsg: string;

  @ApiProperty({ description: '图像宽' })
  width: number;

  @ApiProperty({ description: '图像高度' })
  height: number;

  @ApiProperty({ description: '类型' })
  type: string;

  @ApiProperty({ description: '方向' })
  orientation: string;

  @ApiProperty({ description: '地址' })
  path: string;
}

export class TemplateSize {
  @ApiProperty({ description: '模板宽度' })
  width: number;

  @ApiProperty({ description: '模板高度' })
  height: number;

  @ApiProperty({ description: '编辑区宽度' })
  areaWidth: number;

  @ApiProperty({ description: '编辑区高度' })
  areaHeight: number;

  @ApiProperty({ description: '编辑区距离x' })
  x: number;

  @ApiProperty({ description: '编辑区距离y' })
  y: number;
}

export class Result {
  @ApiProperty({ description: '编辑区缩放系数' })
  editor_scale: number;

  @ApiProperty({ description: '图像缩放系数' })
  scale: number;

  @ApiProperty({ description: '图像位移x' })
  x: number;

  @ApiProperty({ description: '图像位移y' })
  y: number;

  @ApiProperty({ description: '图像原始宽' })
  image_width: number;

  @ApiProperty({ description: '图像原始高' })
  image_height: number;

  @ApiProperty({ description: '图像旋转' })
  rotate: number;

  @ApiProperty({ description: '图像原始信息' })
  imgOriginalInfo: ImgOriginalInfo;

  @ApiProperty({ description: '图像信息' })
  imgInfo: ImgInfo;

  @ApiProperty({ description: '证件添加的名字' })
  text: string;

  @ApiProperty({ description: '传入的模板值' })
  templateSize: TemplateSize;

  @ApiProperty({ description: '组件类型' })
  componentType?: string;

  @ApiProperty({ description: '证件背景色' })
  background: string;

  @ApiProperty({ description: '图像地址cdn' })
  tempFilePath: string;
}
export class MediaSizeFormat {
  @ApiProperty({ description: '拼版的单个图像宽度' })
  width: number;

  @ApiProperty({ description: '拼版的单个图像高度' })
  height: number;
}

export class MediaSetTypeFormat {
  @ApiProperty({ description: '拼版行' })
  row: number;

  @ApiProperty({ description: '拼版列' })
  column: number;
}
export class ModeInfo {
  @ApiProperty({ description: '图像地址' })
  modeSrc?: string;

  @ApiProperty({ description: '证件名' })
  media_name?: string;

  @ApiProperty({ description: '证件物理尺寸' })
  media_size: string;

  @ApiProperty({ description: '证件物理尺寸格式化' })
  mediaSizeFormat: MediaSizeFormat;

  @ApiProperty({ description: '证件类型名' })
  media_type: string;

  @ApiProperty({ description: '证件信息' })
  mediaInfo: MediaSizeFormat;

  @ApiProperty({ description: '证件类型' })
  media_set_type: string;

  @ApiProperty({ description: '证件拼版格式' })
  mediaSetTypeFormat: MediaSetTypeFormat;

  @ApiProperty({ description: '证件拼版数' })
  mediaNum: number;

  @ApiProperty({ description: '证件模板尺寸' })
  modeSize: TemplateSize;
}
export class DrawImageParams {
  @ApiProperty({ description: '图像信息', type: Result })
  imgPoint: Result;

  @ApiProperty({ description: '生成的宽高', type: canvasPaperSize })
  canvasPaperSize: canvasPaperSize;

  @ApiProperty({ description: '模版信息', type: ModeInfo })
  modeInfo: ModeInfo;
}
